const { Router } = require('express')
const express = require('express')
//路由容器
const index = express.Router()
const axios = require('axios')
const qs = require('qs')

index.get('/',(req, res)=>{
    res.render('home/index');
});

index.get('/register', (req, res) => {
    const {name, classes,sex,studentId,telephone,qq}=req.query;
    console.log(req.query);
    // if (pageNow==undefined||pageSize==undefined) {
    //     console.log(req.query);
    //     return res.status(400).render('admin/error',{msg:"参数错误"})
    // }else{
        axios({
            url:"http://1.117.92.175:8081/register",
            method:"POST",
            params: {
                name:name,
                classes:classes,
                sex:sex,
                studentId:studentId,
                telephone:telephone,
                qq:qq,
            }
        })
        .then(data=>{
            console.log(data.data);
            res.send(data.data)
        //    console.log(data.data);
        })
        .catch(err=>{
            res.send(err)
            console.log("err "+"err");
        })
    // }
})
module.exports=index;